package Day03;

public class Homework {
    public static void main(String[] args) {
        //输出几个整数取模，验证结果
        /*
        System.out.println(5 % 2);
        System.out.println(7 % 3);

        //单独用
        int a = 5, b = 4;
        a++;
        b--;
        System.out.println(a);
        System.out.println(b);
        //单独用
        ++a;
        System.out.println(a);
        --b;
        System.out.println(b);
        //被使用
        int c = ++a;
        System.out.println(a);
        c = b--;
        System.out.println(b);
        c = a++;
        System.out.println(a);
        c = --b;
        System.out.println(b);


        //声明几个变量，演示最基本的>，<，>=，<=，==，!=操作

        int d = 7, e = 8, f = 7;
        System.out.println(d >= e);
        System.out.println(d < f);
        System.out.println(e >= d);
        System.out.println(d++ > e);
        System.out.println(e-- <= f);
        System.out.println(++d < e);
        System.out.println(--e < d);
        System.out.println(d != e);

        //演示关系运算符和算术运算符联合使用的效果
        int g = 7, h = 8, i = 7;
        boolean b1 = g > h;
        System.out.println(g+h>i);
        System.out.println(h-i<g);
        System.out.println(g % h==i);




        //&&的演示要求：true+false、false+true、true+true、false+false
        int a = 25, b = 35, c = 25;
        boolean b1 = a <= b && c <= a;
        System.out.println(b1);
        System.out.println(b >= a && c <= b);
        System.out.println(b != c && a == b);

        int age = 70;
        System.out.println(age >= 30 && age <= 70);
        int score = 60;
        System.out.println(score >= 60 && score <= 100);



        //||的演示要求：true+false、false+true、true+true、false+false
        System.out.println(b >= a || b > c);
        System.out.println(b <= c || b > a);
        System.out.println(b != c || a < b);
        System.out.println(a == b || b < c);
        System.out.println(score<=0||score>=100);


        //!的演示要求：true、false
        boolean b2 = !(a>b);
        System.out.println(b1);
        System.out.println(!(a<b));

        //声明一个整型变量，演示扩展赋值+=、-=、*=、/=、%=的效果
        int d = 5;
        d += 10;
        System.out.println(d);
        d *= 2;
        System.out.println(d);
        d /= 6;
        System.out.println(d);




        //声明short型变量s，演示简单赋值运算的自增10，演示扩展赋值运算的自增10
        int s = 10;
        s+=10;
        s=s+10;

        //声明整型变量age和字符串型变量name，输出字符串连接的结果
        int age = 70;
        System.out.print("age=");
        System.out.println(age);
        System.out.println("age=" + age);
        System.out.println("我今年" + age + "岁了");

        String name = "cjc";
        System.out.println("大家好，我叫" + name);
        System.out.println("大家好，我叫" + name + "今年" + age + "岁了");



        //输出几个数据的拼接，演示字符串连接的同化作用
        System.out.println("" + 15 + 25 + 35);
        System.out.println(15 + 25 + 35 + "");
        System.out.println(15 + 52 + "" + 35);



        //声明并初始化整型变量，使用条件运算符实现：若>0则给flag赋值为1，否则赋值为0
        int num = 5;
        int flag = num > 0 ? 1 : -1;
        System.out.println(num);



        //声明两个整型变量，使用条件运算符实现：求这两个变量的最大值
        int a = 9,b = 10;
        int max = a>b?a:b;
        System.out.println(max);



        //满500打8折
        double price = 800;
        if (price>=500){
            price *=0.8;
        }



        //判断成绩是否合法
        int score =85;
        if (score>=0 && score<=100);{
            System.out.println("合法");
        }




        //满500打8折，不满500打9折
        double price = 800;
        if (price>=500){
            price *=0.8;
        }else {
            price *=0.9;
        }




        //判断成绩合法还是不合法
        int score =85;
        if (score>=0 && score<=100){
            System.out.println("合法");
        }else{
            System.out.println("不合法");
        }

*/

        //满2000打5折，满1000不满2000打7折，满500不满1000打8折，不满500打9折
        double price = 60000;//(1111,999,499)
        if (price >= 2000) {
            price *= 0.5;
        } else if (price >= 1000) {
            price *= 0.7;
        } else if (price >= 500) {
            price *= 0.8;
        } else {
            price *= 0.9;
        }
        System.out.println("最终交易金额为" + price);


        //拓展练习
        //声明两个整型变量a和b并分别赋值，找到a和b中的最大值，并输出。用两种方式实现：条件运算 符、if..else分支结构
        int a = 50, b = 30;
        int max = a > b ? a : b;
        System.out.println(max);


        if (a > b) {
            System.out.println(max);
        }


        //声明一个整型变量year并存储年份，判断其是平年还是闰年，若是闰年则输出"某某某年是闰年"， 否则输出"某某某年是平年"
        int year = 1900;
        if (year % 4 == 0 && year % 100 != 0) {
            System.out.println("润");
        } else {
            System.out.println("平");
        }


        //：考虑成绩的合法性：当不合法成绩时，输出"成绩不合法"
        int score = 76;
        if (score < 0 || score > 100){
            System.out.println("成绩不合法");
        } else if (score >=90) {
            System.out.println("A");
        } else if (score >=80) {
            System.out.println("B");
        } else if (score >=70) {
            System.out.println("C");
        }else {
            System.out.println("D");
        }


    }
}
